package programs.statement;

import java.util.ArrayList;
import java.util.List;

public abstract class Loop extends ComposedStatement {
	
	private Statement loopStatement;
	
	public Loop(Statement loopStatement) {
//		if(loopStatement instance of SequenceOfStatements)
//			this.loopStatement = (SequenceOfStatements) loopStatement;
//		else {
//			SequenceOfStatements sequence = new SequenceOfStatements();
//			sequence.addSubStatement(loopStatement);
//			this.loopStatement = sequence;
		this.loopStatement = loopStatement;
			}

	@Override
	public boolean isValidStatement() {
		if(! getLoopStatement().isValidStatement())
			return false;
		else 
			return true;
	}
	
	public Statement getLoopStatement() {
		return this.loopStatement;
	}
	
	@Override
	public int getNbOfSubStatements() {
		return 1;
	}
	
	@Override
	public List<Statement> getAllSubStatements() {
		List<Statement> list = new ArrayList<Statement>();
		list.add(getLoopStatement());
		return list;
	}
	
}